package com.followmeandroid.models;

/**
 * <p>Title: CurrentMember</p>
 * <p>Description: Class model for storing the current
 * member logged into the application.</p>
 * @author Adam Drews
 * @email adam.drews@my.uwrf.edu
 * @date 11/22/2014
 * @team Tyler Johnson
 * @email tyler.johnson@my.uwrf.edu
 * @team Nicholas Thorp
 * @email nicholas.thorp@my.uwrf.edu
 */
public class CurrentMember {

    /**
     * Default constructor.
     */
    private CurrentMember() {
    }

    /**
     * Returns the current member that is logged into the application.
     * @return currentMember.member     The currently logged in member.
     */
    public static synchronized Member getMember() {
        return currentMember.member;
    }

    /**
     * Sets the current member to the given member instance.
     * @param in        The member to be set as the current member.
     */
    public static synchronized void setMember(Member in) {
        currentMember.member = in;
    }

    /**
     * Ends the session, by setting to the currently logged in member as NULL.
     */
    public void endSession() {
        currentMember.member = null;
    }

    /**
     * Nested class to statically store the current member.
     */
    private static class currentMember {
        private static Member member = null;
    }
}
